dhcpv6: use a per-interface IAID for IA_NA requests
authorDavid Härdeman <[email protected]>
Mon, 20 Oct 2025 16:29:36 +0000 (18:29 +0200)
committerÁlvaro Fernández Rojas <[email protected]>
Tue, 21 Oct 2025 16:57:38 +0000 (18:57 +0200)
This ensures that the same IAID isn't used when odhcpd is e.g. running
on different interfaces (RFC8415, §12). This is more important now that
global DUID support has landed [1], meaning that odhcp6c won't typically
use per-interface DUIDs.

[1] https://github.com/openwrt/openwrt/pull/20359

Signed-off-by: David Härdeman <[email protected]>
Link: https://github.com/openwrt/odhcp6c/pull/105
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
src/dhcpv6.c

index fa0c2a1787ca91b7b0b686767b4b37b5a89176a8..2075006b6cc61de772648df563d14284eb590ea5 100644 (file)
@@ -479,9 +479,11 @@ static void dhcpv6_send(enum dhcpv6_msg type, uint8_t trid[3], uint32_t ecs)
        ia_na_entries /= sizeof(*e);
 
        struct dhcpv6_ia_hdr hdr_ia_na = {
-               htons(DHCPV6_OPT_IA_NA),
-               htons(sizeof(hdr_ia_na) - 4),
-               htonl(1), 0, 0
+               .type = htons(DHCPV6_OPT_IA_NA),
+               .len = htons(sizeof(hdr_ia_na) - 4),
+               .iaid = htonl(ifindex),
+               .t1 = 0,
+               .t2 = 0,
        };
 
        struct dhcpv6_ia_addr pa[ia_na_entries];
@@ -1156,7 +1158,7 @@ static int dhcpv6_handle_reply(enum dhcpv6_msg orig, _unused const int rc,
                                        continue;
 
                                // Test ID
-                               if (ia_hdr->iaid != htonl(1) && otype == DHCPV6_OPT_IA_NA)
+                               if (ia_hdr->iaid != htonl(ifindex) && otype == DHCPV6_OPT_IA_NA)
                                        continue;
 
                                uint16_t code = DHCPV6_Success;